package com.example.covid19.controller;


import com.example.covid19.common.lang.Result;
import com.example.covid19.entity.User;
import com.example.covid19.entity.Userf;
import com.example.covid19.common.Dto.editdto;
import com.example.covid19.mapper.UserMapper;
import com.example.covid19.mapper.UserfMapper;
import com.example.covid19.service.UserService;
import com.example.covid19.service.UserinfoService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author BaiZhengChun
 * @since 2022-10-19
 */
@RestController
@RequestMapping("/userinfo")
public class UserinfoController {

    private final UserfMapper userfMapper;
    private final UserMapper userMapper;
    private final UserService userService;
    private final UserinfoService userinfoService;

    public UserinfoController(UserfMapper userfMapper, UserMapper userMapper, UserService userService, UserinfoService userinfoService) {
        this.userfMapper = userfMapper;
        this.userMapper = userMapper;
        this.userService = userService;
        this.userinfoService = userinfoService;
    }


    @RequestMapping("/seinfo2")
    public Result seifo2(@RequestParam("pageNo") Integer pageNo, @RequestParam("pagesize")Integer pagesize){
        int a = (pageNo-1)*pagesize;
        List<User> userfs = userMapper.userinf(a,pagesize);
        return Result.success(200,"返回成功",userfs);
    }
    @RequestMapping("/seinfo")
    public Result seifo(){
        HashMap<Object,Object> hashMap = new HashMap<>();
        Integer i = userMapper.selectCount(null);
        List<User> userfs = userMapper.selectList(null);
        hashMap.put("info",userfs);
        hashMap.put("count",i);
        return Result.success(200,"返回成功",hashMap);
    }
    @RequestMapping("/edit")
    public Result edit(@RequestBody editdto editdto){
       return userinfoService.edit(editdto);

    }

}
